#include "includefile.h"

uint16_t ii;
 int main(void)
{
  //   int aa;
    HardwareInit();   
    while(1)
    {  
        if(cnt_2ms>=2)
        {
            cnt_2ms=0;
            if(flag_MPU_Init==SUCCESS)
            {
                mpu_read_data(acc_original,gyr_original);  
                acc_average_filter(acc_original,&acc_filter);
            }
        }
        if(cnt_5ms>=5) 
        {
            cnt_5ms=0;            
            gyo_filter(gyr_original,&gyr_filter ) ;
            get_attitude();               
        }
        if(cnt_10ms>=10)  //100hz
        { 
            cnt_10ms=0;    
            convert_ppm();
            ctrl_attitude();  
        }
        if(cnt_50ms>=20)    
        { 
            cnt_50ms=0;
            mag_read(mag_original); 
            mag_average_filter(mag_original,&mag_filter); 
            if(USART1_REG_RX_OK)
            {
              USART1_REG_RX_Reset;
              rec_analysis(receivebuf,usart_rec_length);
            }
            else
            {
               tra_info_to_pc(); 
            }
        }               
        
    }
}


